package org.argus.job.worker.nacos.network;

import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import org.argus.job.common.network.IServiceInstanceIPParser;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Nacos Worker IP 解析器，获取注册中心的IP，避免多网卡场景下worker ip解析错误
 * @Author 刘文/Cliff Liu
 * @Date 2024/9/15
 */
@Component
public class NacosServiceInstanceIPParser implements IServiceInstanceIPParser {
    @Resource
    private NacosDiscoveryProperties nacosDiscoveryProperties;

    /**
     * 获取当前Worker的IP
     *
     * @return
     */
    public String getInstanceIp() {
        return nacosDiscoveryProperties.getIp();
    }
}
